const sql = require("../../config/config");

// 获取banner
function getBanner() {
  return sql("select * from banner");
}

// 添加banner
function addBanner(arr) {
  return sql("insert into banner value (NULL,?,?,?,1,?)", arr);
}

// 更新banner
function updateBanner(arr) {
  return sql("update banner set src = ? , url = ? , atime = ? where banner_id = ?", arr);
}

// 删除banner
function deleteBanner(arr) {
  return sql("delete from banner where banner_id = ?", arr);
}

// 是否展示banner
function showBanner(arr) {
  return sql("update banner set isShow = ? where banner_id = ?", arr);
}

// 批量删除
function batchDelete(arr) {
  return sql("delete from banner where banner_id in(?)",arr);
}

module.exports = {
  getBanner,
  addBanner,
  updateBanner,
  deleteBanner,
  showBanner,
  batchDelete
};
